package hr.tvz.lab.tom.malwaredb.info;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import hr.tvz.lab.tom.malwaredb.R;

/**
 * RecyclerView Adapter for MalwareObject links in InfoActivity.
 */
public class RecyclerViewInfoLinksAdapter extends RecyclerView.Adapter<RecyclerViewInfoLinksAdapter.ViewHolder> {

    List<String> linkList;

    public RecyclerViewInfoLinksAdapter(List<String> mediaList) {
        this.linkList = mediaList;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        TextView textLink;

        public ViewHolder(View itemView) {
            super(itemView);
            textLink = (TextView) itemView.findViewById(R.id.textLink);
        }
    }

    @Override
    public RecyclerViewInfoLinksAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_view_list_link, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerViewInfoLinksAdapter.ViewHolder holder, int position) {
        holder.textLink.setText(linkList.get(position));
        holder.textLink.setId(position);
    }

    @Override
    public int getItemCount() {
        return linkList.size();
    }
}
